<?php
require_once 'tools/db/DbUtils.php';
class Runner{
	
	public $id;
	public $nom;
	public $prenom;
	public $date;
	public $sex;
	public $club;

	function Runner($nom,$prenom,$date,$sex,$club){
		$this->nom=$nom;
		$this->prenom=$prenom;
		$this->sex=$sex;
		
		if(!isset($club)){
			$this->club=$club;
		}else{
			$this->club=$club;
		}
		
		if(!isset($date)){
			$this->date="1900-00-00";
		}else{
			$this->date=$date;
		}
	}
	
	
	function isValid(){
		return isset($this->nom) && isset($this->prenom) && isset($this->sex) && isset($this->club);
	}
	function persist($dbUtils){
		$dbUtils->saveRunner($this->nom,$this->prenom,$this->date,$this->sex,$this->club);
		$this->id=$dbUtils->getLastId();
		return $this->id;
	}
	
	

}